from math import gcd

ans=0
for i in range(1,2021):
    for j in range(1,2021):
        # 最大公约数gcd
        if gcd(i,j)==1:
            ans+=1
print(ans)